﻿Imports System.Windows
Imports System.Collections.ObjectModel
Imports Microsoft.Practices.Prism.Commands

Public Class ViewModelNouveauPMT
    Inherits ViewModelTabSectionBase

    Private _ViewModelNouveauPMTArbo As ViewModelNouveauPMTArbo

#Region "Année et mois de réalisation du nouveau PMT"

    Public ReadOnly Property ListeAnneeRealisation As List(Of Integer)
        Get
            Return New List(Of Integer)({2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020})
        End Get
    End Property
    Public Property CurrentAnneeRealisation As Integer
        Get
            Return _currentAnneeRealisation
        End Get
        Set(value As Integer)
            _currentAnneeRealisation = value
            MAJ_ViewModelNouveauPMTArbo()
            OnPropertyChanged("IsMoisAnneeValide")
            OnPropertyChanged("RacineParametres")
            OnPropertyChanged("RacineInfocentre")
        End Set
    End Property
    Private _currentAnneeRealisation As Integer

    Public ReadOnly Property ListeMoisRealisation As List(Of String)
        Get
            Return New List(Of String)({"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"})
        End Get
    End Property
    Public Property CurrentMoisRealisation As String
        Get
            Return _currentMoisRealisation
        End Get
        Set(value As String)
            _currentMoisRealisation = value
            MAJ_ViewModelNouveauPMTArbo()
            OnPropertyChanged("IsMoisAnneeValide")
            OnPropertyChanged("RacineParametres")
            OnPropertyChanged("RacineInfocentre")
        End Set
    End Property
    Private _currentMoisRealisation As String

    Public ReadOnly Property IsMoisAnneeValide As Boolean
        Get
            Return (ListeAnneeRealisation.Contains(_currentAnneeRealisation) And ListeMoisRealisation.Contains(_currentMoisRealisation))
        End Get
    End Property
    Private Sub MAJ_ViewModelNouveauPMTArbo()
        If IsMoisAnneeValide Then
            If _ViewModelNouveauPMTArbo Is Nothing Then
                _ViewModelNouveauPMTArbo = New ViewModelNouveauPMTArbo(CurrentAnneeRealisation & CurrentMoisRealisation)
            Else
                _ViewModelNouveauPMTArbo.Mois = CurrentAnneeRealisation & CurrentMoisRealisation
            End If
        End If
    End Sub

#End Region

#Region "Racine des paramètres et de l'infocentre"
    Public ReadOnly Property RacineParametres As String
        Get
            'Faire résoudre pas le moteur l'expression récupérée dans le XML puis retourner la chaîne de caractère
            If Not _ViewModelNouveauPMTArbo Is Nothing Then
                Return _ViewModelNouveauPMTArbo.NomRacineParametres
                'Return "Q:\Technique_Collectives\00_Emprunteur\08_Projets_Applications_Informatiques\03_NASA_e\04_REC_Recette\01_OMANE\02_PMT"
            Else
                Return "-"
            End If
        End Get
    End Property
    Public ReadOnly Property RacineInfocentre As String
        Get
            If Not _ViewModelNouveauPMTArbo Is Nothing Then
                Return _ViewModelNouveauPMTArbo.NomRacineInfocentre
                'Return "Q:\Technique_Collectives_Donnees\05_PMT\&mois\InputNASA"
            Else
                Return "-"
            End If
        End Get
    End Property
#End Region

    Private _OuvrirConfigArbo As New DelegateCommand(AddressOf OuvrirConfigArboCanExecute, AddressOf OuvrirConfigArboExecute)
    Public ReadOnly Property OuvrirConfigArbo As delegateCommand
        Get
            Return _OuvrirConfigArbo
        End Get
    End Property
    Private Function OuvrirConfigArboCanExecute() As Boolean
        Return True
    End Function
    Private Function OuvrirConfigArboExecute() As Boolean
        If IsMoisAnneeValide Then
            Dim ConfigArbo As New WindowNouveauPMTConfigArbo
            ConfigArbo.DataContext = _ViewModelNouveauPMTArbo
            ConfigArbo.Show()
        End If
        Return True
    End Function



    Public Property UtiliserPMTreference As Boolean = True

    'A remplir en fonction des PMT récupérés dans le profil utilisateur
    Public Property CurrentPMTreference As String
    Public Property ListePMTreference As ObservableCollection(Of String)

End Class